<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                template="./template/StakeholderTemplate.xhtml">
    <ui:define name="begin">
        <f:view beforePhase="#{tableManagerBean.initEditTableTypeInfo}"></f:view>
    </ui:define>

    <ui:define name="contentInsert">
        <h:body>    
            <h:form>
                <h1>table Edit Table Type Info</h1>

                <p:panel id="panel" header="Edit a table type's information">
                    <p:ajaxStatus style="width:16px;height:16px;">
                        <f:facet name="start">
                            <h:graphicImage value="http://www.primefaces.org:8080/showcase/design/ajaxloading.gif" />
                        </f:facet>
                        <f:facet name="complete">
                            <h:outputText value="" />
                        </f:facet>
                    </p:ajaxStatus>
                    <p:messages />

                    <h:panelGrid columns="3" columnClasses="column" cellpadding="5">   
                        <h:outputText value="Table type name: " />
                        <p:inputText required="true" requiredMessage="Table type name is required." id="tabletypename" value="#{tableManagerBean.tableType.name}">
                            <p:ajax event="blur" update="tabletypenameMsg" />
                        </p:inputText>
                        <p:message id="tabletypenameMsg" for="tabletypename" />

                        <h:outputText value="Unit capacity: " />
                        <h:selectOneMenu value="#{tableManagerBean.tableType.unitCapacity}" id="unitcapacitylist">
                            <f:selectItem itemLabel="1 person" itemValue="1"></f:selectItem>
                            <f:selectItem itemLabel="2 persons" itemValue="2"></f:selectItem>
                            <f:selectItem itemLabel="3 persons" itemValue="3"></f:selectItem>
                            <f:selectItem itemLabel="4 persons" itemValue="4"></f:selectItem>
                            <f:selectItem itemLabel="5 persons" itemValue="5"></f:selectItem>
                            <f:selectItem itemLabel="6 persons" itemValue="6"></f:selectItem>
                            <f:selectItem itemLabel="7 persons" itemValue="7"></f:selectItem>
                            <f:selectItem itemLabel="8 persons" itemValue="8"></f:selectItem>
                            <f:selectItem itemLabel="9 persons" itemValue="9"></f:selectItem>
                            <f:selectItem itemLabel="10 persons" itemValue="10"></f:selectItem>
                            <f:selectItem itemLabel="11 persons" itemValue="11"></f:selectItem>
                            <f:selectItem itemLabel="12 persons" itemValue="12"></f:selectItem>
                            <f:selectItem itemLabel="13 persons" itemValue="13"></f:selectItem>
                            <f:selectItem itemLabel="14 persons" itemValue="14"></f:selectItem>
                            <f:selectItem itemLabel="15 persons" itemValue="15"></f:selectItem>
                            <f:selectItem itemLabel="16 persons" itemValue="16"></f:selectItem>
                            <f:selectItem itemLabel="17 persons" itemValue="17"></f:selectItem>
                            <f:selectItem itemLabel="18 persons" itemValue="18"></f:selectItem>
                            <f:selectItem itemLabel="19 persons" itemValue="19"></f:selectItem>
                            <f:selectItem itemLabel="20 persons" itemValue="20"></f:selectItem>
                        </h:selectOneMenu>
                        <p:message id="unitcapacitylistMsg" for="unitcapacitylist" />

                        <h:outputText value="Description: " />
                        <p:inputTextarea required="true" requiredMessage="Description should be provided" style="width:300px;height:100px;" effectDuration="400" id="description" value="#{tableManagerBean.tableType.description}">
                            <p:ajax event="blur" update="descriptionMsg" />
                        </p:inputTextarea>    
                        <p:message id="descriptionMsg" for="description" />

                        <h:outputText value="Image display: " />
                        <p:graphicImage id="imageDisplay" value="/images/#{tableManagerBean.tableType.imageURL}"
                                        height="500" width="500"/> 
                        <p:message id="imageDisplayMsg" for="imageDisplay"/>

                        <h:outputText value="Reupload image: " />                     
                        <p:fileUpload id="imageURL" fileUploadListener="#{tableManagerBean.handleTableImageUpload}" 
                                      allowTypes="*.jpg;*.png;*.gif;" description="Images" sizeLimit="524288" update="imageDisplay">
                        </p:fileUpload>
                        <p:message id="imageURLMsg" for="imageURL"/> 

                    </h:panelGrid>
                    <p:commandButton value="Submit" update="panel" action="BranchViewTableTypes?faces-redirect=true" actionListener="#{tableManagerBean.editTableTypeInfo}" ajax="true"/>                               
                </p:panel>

            </h:form>
        </h:body>
    </ui:define>
</ui:composition>
